from xlrd import open_workbook
import numpy as np
# x_data1=[]
# y_data1=[]
# wb = open_workbook("500组工艺参数.xlsx")
# for s in wb.sheets():
#     print("sheet",s.name)
#     for row in range(s.nrows):
#         print("the row is",row)
#         values = []
#         for col in range(s.ncols):
#             values.append(s.cell(row,col).value)
#         print(values)
#         x_data1.append(values[0])
#         y_data1.append(values[1])
#
import matplotlib.pyplot as plt
np.set_printoptions(precision=3)
fig =plt.figure(figsize=(12.8,9.6))
data = open_workbook("500组工艺参数.xlsx")
table = data.sheets()[0]
y = ""
xx = table.row_values(0)
for i in range(len(xx)):
#     ax = fig.add_subplot(5,2,i+1)
#     y = table.col_values(i)
#     y1 = y[1:]
#     lists = [x for x in y1 if type(x)==float]
#     lists.sort()
#     t = np.array(lists)
#     plt.rcParams['font.sans-serif']=['SimHei']
#     plt.hist(t,bins=40,color="b",alpha=0.3)
#     #plt.title(str(y[0]))
#     plt.ylabel("炉次")
#     xlabel =str("("+chr(97+i)+")   " + y[0])
#     plt.xlabel(xlabel)
#
# plt.subplots_adjust(wspace =0.2, hspace =0.5)
# plt.savefig('x_all.jpg', dpi=300)

    y = table.col_values(i)
    y1 = y[1:]
    lists = [x for x in y1 if type(x)==float]
    lists.sort()
    t = np.array(lists)
    plt.cla()
    plt.rcParams['font.sans-serif']=['SimHei']
    plt.hist(t,bins=40,color="b",alpha=0.3)
    #plt.title(str(y[0]))
    plt.ylabel("炉次")
    xlabel =str("("+chr(97+i)+")   " + y[0])
    plt.xlabel(xlabel)

    # plt.subplots_adjust(wspace =0.2, hspace =0.5)
    plt.savefig('x_%d.jpg'%(i+1), dpi=300)
